#ifndef REGISTER_DIALOG_HPP
#define REGISTER_DIALOG_HPP

#include <QDialog>
#include <QLineEdit>
#include <QLabel>
#include <QPushButton>
#include <QFormLayout>
#include <QMessageBox>

#include "../client.h"

// 前向声明
class ClientWrapper;

class RegisterDialog : public QDialog
{
    Q_OBJECT

public:
    explicit RegisterDialog(ClientWrapper *clientWrapper, QWidget *parent = nullptr);
    ~RegisterDialog();

signals:
    void registerSuccessful(const QString &username);

private slots:
    void onRegisterClicked();
    bool validateInput();
    void onCancelClicked();
    void onRegistrationFinished(bool success, const QString &message);

private:
    void setupUI();
    void showError(const QString &title, const QString &message);

    ClientWrapper *m_clientWrapper;

    // UI控件
    QLineEdit *m_usernameEdit;
    QLineEdit *m_emailEdit;
    QLineEdit *m_passwordEdit;
    QLineEdit *m_confirmPasswordEdit;
    QLabel *m_statusLabel;
    QPushButton *m_registerButton;
    QPushButton *m_cancelButton;
};

#endif // REGISTER_DIALOG_HPP